#include "llt_router.hh"

using namespace userPPF;

void
router::processData(lee::PktData * const pkt)
{
  tt::Packet * packet = static_cast<tt::Packet *>(pkt);
  const tt::FiveTuple & ft = packet->getFiveTuple();
  unsigned int D = ft.daddr & 0xFF;
  if(D < 50) {
    opt0(pkt);
  }
  else if(D<100) {
    opt1(pkt);
  }
  else if(D<150) {
    opt2(pkt);
  }
  else if(D<200) {
    opt3(pkt);
  }
  else {
    drop(pkt);
  }
  checkCount();
  return;
}

void
router::checkCount()
{
  lee::Synchronized::Scope mutex(this);
  count++;
  if(count == 50000) {
    std::cout << "Routed the packets." << std::endl;
  }
}
